<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<script type="text/javascript" src="jquery.min.js"></script>
<body>
	<div class="box">
		<input type="file" name="file" id="file"></input>
		<span>50%</span>
	</div>
	<script type="text/javascript">
		$(function(){
                $(".box").click(function(){
                	let fileObject = document.getElementById('file').files[0];
                	let formDataes = new FormData();
                	formDataes.append('file',fileObject)
                	formDataes.set('name','111');
                	formDataes.set('action', 'vote_post_lists'); 
                	$.ajax({
                		type:'post',
                		url:'https://stg-iu4193.elementor.cloud/wp-admin/admin-ajax.php',
                		data:formDataes,
                		contentType: false,
                		processData: false,
						beforeSend: function() {
							$('.area').text('上传中');
						},
						xhr:function() {
							var xhr = $.ajaxSettings.xhr();
							if (xhr.upload) {
								xhr.upload.onprogress = function(e) {
									if (e.lengthComputable) {
										var percent = Math.floor( e.loaded / e.total * 100);
										console.log(percent);
									}
								};
							}
							return xhr;
						},
						success: function(res) {

						},
						error: function(res) {
							
						}
                	})
                })
		})
	</script>
</body>
</html>